<?php
/**
 * User: leewei
 * Date: 2019/6/21 0021
 * Time: 下午 5:20
 */
namespace app\common\tools;

class Common  {

    private $debug = [];
    protected $userInfo;

    public static function buildSuccess($data, $msg = '操作成功', $code) {
        $return = [
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ];

        return $return;
    }



    function buildFailed($code, $msg, $data = []) {
        $return = [
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ];
        if ($this->debug) {
            $return['debug'] = $this->debug;
        }

        return $return;
    }

    protected function debug($data) {
        if ($data) {
            $this->debug[] = $data;
        }
    }
}